package SwordFingerOffer;

public class Q27_MirrorTree {

    //输出镜像二叉树
    //先序调换
    public TreeNode mirrorTree(TreeNode root) {
        if (root == null){
            return null;
        }
        process(root);
        return root;
    }

    //只负责其子节点的调换
    public void process(TreeNode root) {
        //尾节点
        if (root.left == null && root.right == null){
            return;
        }

        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;
        if (root.left != null)
        process(root.left);
        if (root.right != null)
        process(root.right);
    }
}
